package com.sanhuo.security.global;

public class ResponseUtil {
    public static Response success(Object data){
        return new Response(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(),data);

    }
    public static Response success(Integer code, String msg){
        if (null==msg) msg= ResponseEnum.SUCCESS.getMsg();
        if (null==code) code= ResponseEnum.SUCCESS.getCode();
        return new Response(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg());
    }


    public static Response success(ResponseEnum resultEnum){
        return success(resultEnum.getCode(),resultEnum.getMsg());
    }

    public static Response fail(String msg){
        if (null==msg) msg= ResponseEnum.FAIL.getMsg();
        return new Response(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg());

    }
    public static Response fail(Integer code, String msg){
        if (null==msg) msg= ResponseEnum.FAIL.getMsg();
        if (null==code) code= ResponseEnum.FAIL.getCode();
        return new Response(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg());

    }
    public static Response fail(ResponseEnum resultEnum){
        return fail(resultEnum.getCode(),resultEnum.getMsg());
    }
}
